package com.cardone.platform.configuration.function;

import com.cardone.context.function.Execution0Function;
import com.cardone.platform.configuration.util.DictionaryUtils;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

/**
 * Created by c100000002 on 15-1-30.
 */
public class ReadDictionaryIdFunction implements Execution0Function<Object> {
    @Setter
    private String defaultId;

    @Setter
    private String typeCode = "DATA_STATE_TYPE";

    @Setter
    private String code = "activity";

    @Override
    public Object execution() {
        if (StringUtils.isNotBlank(defaultId)) {
            return defaultId;
        }

        defaultId = DictionaryUtils.readIdByTypeCodeAndCode(defaultId, typeCode, code);

        return defaultId;
    }
}
